﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication6.BIZ;
using MvcApplication6.Models;

namespace MvcApplication6.Controllers
{
    public class CategoryEventController : Controller
    {
        //
        // GET: /SalePerson/

        Category_eventBIZ BIZ_Category = new Category_eventBIZ();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult categoryEvent(Category_eventModel model)
        {
            if (Request["cmdInsert"] != null)
            {
                int check = BIZ_Category.Category_eventInsert(model.Name, model.Content_template);
                return RedirectToAction("categoryEvent");
            }
            else if (Request["cmdUpdate"] != null)
            {
                int check = BIZ_Category.Category_eventUpdate(model.Id, model.Name, model.Content_template);
                return RedirectToAction("categoryEvent");
            }
            else if (Request["cmdDelete"] != null)
            {
                int check = BIZ_Category.Category_eventDelete(model.Id);
                return RedirectToAction("categoryEvent");
            }
            else if (Request["cmdEdit"] != null)
            {
                model = BIZ_Category.Category_eventSearchById(model.Id);
            }

            ViewBag.categoryEvent = BIZ_Category.Category_eventSearch();

            return View(model);
        }
    }
}
